package I.O;

//copy本文件代码至IOcopy
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class IOcopy {

	public static void main(String[] args) {
		FileInputStream inf = null;
		FileOutputStream wf = null;
		try {
			String s = "C:\\Java\\eclipse\\wzy\\IO\\src\\I\\O";
			File f = new File(s);
			
			if(!f.isFile()){
				System.out.println("文件夹不能拷贝");
				throw new IOException("文件夹不能拷贝");
			}
			
			inf = new FileInputStream(f);
			wf = new FileOutputStream(s+"\\n.java");
			int c;
			while ((c = inf.read()) != -1) {
				wf.write(c);
			}
			wf.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if(null != inf){
					inf.close();	
				}
				if(null != inf){
					wf.close();
				}				
			} catch (IOException e) {
				e.printStackTrace();
			}

		}
	}
}
